
import 'package:flutter/material.dart';
import 'package:flutter_deer/account/iview/takeout_list_iview.dart';
import 'package:flutter_deer/account/models/user_score_takeout_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/net.dart';
import 'package:flutter_deer/res/constant.dart';


class TakeoutListPresenter extends BasePagePresenter<TakeoutListIMvpView> {

  TakeoutListPresenter();

  @override
  void initState() {
  }

  Future<dynamic> fetchList(String? status) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['size'] = Constant.pageSize;
      params['current'] = 1;
      params['status'] = status;
      asyncRequestNetwork<BaseEntity<UserScoreTakeoutPageEntity>>(Method.get,
        url: HttpApi.takeoutList,
        queryParameters: params,
        onSuccess: (data) {
          view.setTakeoutPage(data!.data);
        },
        onError: (code,msg){

        }
      );
    });
  }

  Future<dynamic> getMoreTakeOutList(String? status,int? pageNo) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['size'] = Constant.pageSize;
      params['current'] = pageNo;
      params['status'] = status;
      asyncRequestNetwork<BaseEntity<UserScoreTakeoutPageEntity>>(Method.get,
        url: HttpApi.takeoutList,
        queryParameters: params,
        onSuccess: (data) {
          view.setTakeoutPage(data!.data);
        },
        onError: (code,msg){

        }
      );
    });
  }

}